package com.example.wechat.csdnandroid.activity;
 
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.wechat.csdnandroid.R;
import com.example.wechat.csdnandroid.service.ForegroundService;


public class ForegroundActivity extends Activity {
 
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_foreground);
    Button btnStart= (Button) findViewById(R.id.startForeground);
    Button btnStop= (Button) findViewById(R.id.stopForeground);
    final Intent intent = new Intent(this, ForegroundService.class);
 
 
    btnStart.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        intent.putExtra("cmd",0);//0,开启前台服务,1,关闭前台服务
        startService(intent);
      }
    });
 
 
    btnStop.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        intent.putExtra("cmd",1);//0,开启前台服务,1,关闭前台服务
        startService(intent);
      }
    });
  }
}